<template>
  <div class="avue-top" style="display: flex;align-items: center;justify-content: space-between;padding-left: 30px">
<!--    <div class="top-bar__left">-->
<!--      <div class="avue-breadcrumb"-->
<!--           :class="[{ 'avue-breadcrumb&#45;&#45;active': isCollapse }]"-->
<!--           v-if="showCollapse">-->
<!--        <i class="icon-navicon"-->
<!--           @click="setCollapse"></i>-->
<!--      </div>-->
<!--    </div>-->
    <div style="font-size: 14px;font-family: Source Han Sans CN;font-weight: 400;color: #666666;">{{routerName}}</div>

    <div class="top-bar__right">
        <div >
          <span v-if="showSearch">
           <top-search></top-search>
         </span>
        </div>

      <el-tooltip v-if="showLock"
                  effect="dark"
                  :content="$t('navbar.lock')"
                  placement="bottom">
        <div class="top-bar__item" style="margin-left: 20px">
          <top-lock></top-lock>
        </div>
      </el-tooltip>
      <el-tooltip
                  effect="dark"
                  content="修改密码"
                  placement="bottom">
        <div class="top-bar__item" style="margin-left: 20px">
          <div style="display: flex;align-items: flex-end">
          <img src="https://yulonghuyu.oss-cn-hangzhou.aliyuncs.com/app-web/xitong/%E7%BB%84%204%402x.png" style="width: 20px;height: 21px" @click="updatepasswordoff()">
          </div>
        </div>
      </el-tooltip>
      <el-tooltip v-if="showFullScren"
                  effect="dark"
                  :content="isFullScren?$t('navbar.screenfullF'):$t('navbar.screenfull')"
                  placement="bottom">
        <div class="top-bar__item" style="margin-left: 20px">
<!--          <i :class="isFullScren?'icon-tuichuquanping':'icon-quanping'"-->
<!--             @click="handleScreen"></i>-->
          <div style="display: flex;align-items: flex-end">
            <img src="https://yulonghuyu.oss-cn-hangzhou.aliyuncs.com/app-web/xitong/%E5%9C%86%E8%A7%92%E7%9F%A9%E5%BD%A2%2016%20%E6%8B%B7%E8%B4%9D%204%402x.png" style="width: 20px;height: 21px" @click="handleScreen">
          </div>
        </div>
      </el-tooltip>
      <img class="top-bar__img" style="margin-left: 20px"
           :src="userInfo.avatar">
      <el-dropdown >
        <span class="el-dropdown-link">
          {{userInfo.account}}
           <span v-if="userInfo.level==4">(组员)</span>
           <span v-if="userInfo.level==3">(组长)</span>
           <span v-if="userInfo.level==2">(主管)</span>
           <span v-if="userInfo.level==1">(会长)</span>
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <router-link to="/">{{$t('navbar.dashboard')}}</router-link>
          </el-dropdown-item>
<!--          <el-dropdown-item>-->
<!--            <router-link to="/info/index">{{$t('navbar.userinfo')}}</router-link>-->
<!--          </el-dropdown-item>-->
          <el-dropdown-item @click.native="logout"
                            divided>{{$t('navbar.logOut')}}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      </div>

  </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
import { fullscreenToggel, listenfullscreen } from "@/util/util";
import topLock from "./top-lock";
import topMenu from "./top-menu";
import topSearch from "./top-search";
import topTheme from "./top-theme";
import topLogs from "./top-logs";
import topColor from "./top-color";
import topLang from "./top-lang";
import {getStore} from "@/util/store";
export default {
  components: {
    topLock,
    topMenu,
    topSearch,
    topTheme,
    topLogs,
    topColor,
    topLang
  },
  name: "top",
  data() {
    return {};
  },
  filters: {},
  created() {
    console.log("userInfouserInfo",this.userInfo)
    console.log("routerName",getStore({name:"routerName"}))
  },
  mounted() {
    listenfullscreen(this.setScreen);
  },
  computed: {
    ...mapState({
      showDebug: state => state.common.showDebug,
      showTheme: state => state.common.showTheme,
      showLock: state => state.common.showLock,
      showFullScren: state => state.common.showFullScren,
      showCollapse: state => state.common.showCollapse,
      showSearch: state => state.common.showSearch,
      showMenu: state => state.common.showMenu,
      showColor: state => state.common.showColor,
      routerName: state => state.common.routerName
    }),
    ...mapGetters([
      "userInfo",
      "isFullScren",
      "tagWel",
      "tagList",
      "isCollapse",
      "tag",
      "logsLen",
      "logsFlag"
    ])
  },
  methods: {
    handleScreen() {
      fullscreenToggel();
    },
    updatepasswordoff(){
      var routerName = "安全管理 > 修改密码"
      this.$store.commit("SET_ROUTERNAME",routerName);
      this.$router.push({ path: "/security/updatepass" });

    },
    setCollapse() {
      this.$store.commit("SET_COLLAPSE");
    },
    setScreen() {
      this.$store.commit("SET_FULLSCREN");
    },
    logout() {
      this.$confirm(this.$t("logoutTip"), this.$t("tip"), {
        confirmButtonText: this.$t("submitText"),
        cancelButtonText: this.$t("cancelText"),
        type: "warning"
      }).then(() => {
        this.$store.dispatch("LogOut").then(() => {
          this.$router.push({ path: "/login" });
        });
      });
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
